from django.conf.urls.defaults import *
from django.conf import settings
import os

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Example:
    # (r'^iperscribo/', include('iperscribo.foo.urls')),

    # Uncomment the admin/doc line below and add 'django.contrib.admindocs' 
    # to INSTALLED_APPS to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    (r'^admin/', include(admin.site.urls)),
    #Project Page
    (r'^(?P<project_uid>\w*)/p/(?P<page_uid>\w*)/t/(?P<tag_name>\w*)/get_content/$', 'pages.views.get_content'),
    (r'^(?P<project_name>\w*)/p/(?P<page_path>[\/\w]*)/$', 'projects.views.view_project'),
    
    (r'^(?P<projectname>\w*)/status/$', 'projects.views.view_project_status'),
    (r'^(?P<project_name>\w*)/addpage/(?P<page_path>[\/\w]*)/$', 'pages.views.add'),
    (r'^(?P<project_name>\w*)/tree/get/$', 'projects.views.get_tree'),

    (r'^pages/editor/(?P<page_uid>[\/\w]*)/$', 'pages.views.view_editor'),
    (r'^pages/editorframe/(?P<page_uid>\w*)/(?P<tag_name>\w*)/$', 'pages.views.view_editor_frame'),
    (r'^pages/save/(?P<tag_uid>\w*)/$', 'pages.views.save'),
    
        
    #(r'^pages/editorframe/(?P<pagepath>[\/\w]*)/$', 'pages.views.view_editor_frame'),
    
    (r'^(?P<project_uid>\w*)/pages/showrev/(?P<revision_uid>\w*)/$', 'pages.views.openrevision'),
    #(r'^(?P<project_uid>\w*)/pages/(?P<page_uid>\w*)/save/$', 'pages.views.savepage'),
    
    (r'^(?P<projectname>\w*)/pages/history/(?P<pagepath>[\/\w]*)', 'pages.views.openpagehistory'),
    #(r'^(?P<projectname>\w*)/pages/(?P<pagepath>[\/\w]*)//history/?$', 'pages.views.openpagehistory'),

    #(r'^(?P<projectname>\w*)/pages/(?P<pagepath>[\/\w]*)', 'pages.views.openpage'),
        
    (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
    (r'^images/(?P<path>.*)$', 'django.views.static.serve', {'document_root': os.path.join(settings.MEDIA_ROOT, 'extjs')}),
    
    (r'^accounts/login/$', 'django.contrib.auth.views.login'),
    (r'^accounts/logout/$', 'django.contrib.auth.views.logout'),
    (r'addproject/(?P<project_name>\w*)$', 'projects.views.add_project'),

    (r'^(?P<project_name>\w*)/$', 'projects.views.view_project'),
    
    (r'^(?P<project_uid>\w*)/messages/', include( 'iperscribo.messages.urls' ) )


)
